#!/bin/bash

JAR=$1
MAIN=$2
ARGS=$3
HOST=$4
SEED=$5

echo "jar  = $JAR"
echo "main = $MAIN"
echo "args = $ARGS"
echo "host = $HOST"
echo "seed = $SEED"

echo "Preparing directory..."
ssh -x $HOST "rm -rf /tmp/$SEED" > /dev/null
ssh -x $HOST "mkdir /tmp/$SEED" > /dev/null
echo "done."

echo "Copying jar..."
scp $JAR "$HOST:/tmp/$SEED/."  > /dev/null
echo "done."

echo "Running..."
#ssh -x "$HOST" " ls"
ssh -x $HOST "cd /tmp/$SEED/;java -cp $JAR $MAIN $ARGS" &
echo "done."



